<?php 
	Class Flight extends CI_Controller{
		public function __construct(){
			parent::__construct();
			$this->load->model("model_flight");
			$this->load->model("model_flightbanner");
			$this->load->model("model_restaurant");
			$this->load->model("model_activity");
			$this->load->model("model_package");
			$this->load->model("model_car");
			$this->load->model("model_guild");
		}	
		
		public function oneway(){
			$departuredate='';
			if(isset($_GET['departuredate'])) $departuredate=date("Y-m-d",strtotime($_GET['departuredate']));
			$departfrom='';
			if(isset($_GET['departfrom'])){
				if(intval($_GET['departfrom'])==1) $departfrom="Bagan";	
				if(intval($_GET['departfrom'])==2) $departfrom="Inle";
				if(intval($_GET['departfrom'])==3) $departfrom="Mandalay";	
				if(intval($_GET['departfrom'])==4) $departfrom="Yangon";	
			}
			$arriveto='';
			if(isset($_GET['arriveto'])){
				if(intval($_GET['arriveto'])==1) $arriveto="Bagan";	
				if(intval($_GET['arriveto'])==2) $arriveto="Inle";
				if(intval($_GET['arriveto'])==3) $arriveto="Mandalay";	
				if(intval($_GET['arriveto'])==4) $arriveto="Yangon";	
			}			
			$data['data']=$this->model_flight->get_search($departfrom,$arriveto,$departuredate,'timedeparture','','',10,0);			
			//if(count($data['data'])>0) 
			$data['listbanner']=$this->model_flightbanner->listall(100,0);
			//var_dump($data['listbanner']);die();
			//else $data['listbanner']=NULL;
			
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($arriveto,0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($arriveto,0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($arriveto,0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($arriveto,2,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($arriveto,0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($arriveto,0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='flight/oneway';
			$this->load->view('layout',$data);
		}
		
		public function roundtrip(){	
			$departfrom='';
			if(isset($_GET['departfrom'])){
				if(intval($_GET['departfrom'])==1) $departfrom="Bagan";	
				if(intval($_GET['departfrom'])==2) $departfrom="Inle";
				if(intval($_GET['departfrom'])==3) $departfrom="Mandalay";	
				if(intval($_GET['departfrom'])==4) $departfrom="Yangon";	
			}
			$arriveto='';
			if(isset($_GET['arriveto'])){
				if(intval($_GET['arriveto'])==1) $arriveto="Bagan";	
				if(intval($_GET['arriveto'])==2) $arriveto="Inle";
				if(intval($_GET['arriveto'])==3) $arriveto="Mandalay";	
				if(intval($_GET['arriveto'])==4) $arriveto="Yangon";	
			}		
			if(isset($_GET['oneway'])){				
				$data['data']=$this->model_flight->get_search($arriveto,$departfrom,$_GET['returningdate'],'timedeparture','','',10,0);	
				$data['listbanner']=$this->model_flightbanner->listall(100,0);
			}
			
			
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($arriveto,0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($arriveto,0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($arriveto,0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($arriveto,2,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($arriveto,0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($arriveto,0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='flight/roundtrip';
			$this->load->view('layout',$data);
		}
		
		public function flightinmyanmar(){
			$data['ym']=$this->model_flight->countbydepart_arrive('Yangon','Mandalay');
			$data['yb']=$this->model_flight->countbydepart_arrive('Yangon','Bagan');
			$data['yi']=$this->model_flight->countbydepart_arrive('Yangon','Inle');
			$data['bi']=$this->model_flight->countbydepart_arrive('Bagan','Inle');
			$data['bm']=$this->model_flight->countbydepart_arrive('Bagan','Mandalay');
			$data['im']=$this->model_flight->countbydepart_arrive('Inle','Mandalay');
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='flight/myanmar';
			$this->load->view('layout',$data);
		}
	}
?>